home *** CD-ROM | disk | FTP | other *** search
/ Power CD / Power CD ATARI-Rechner Lieben.iso / UTILITY / EASYFSEL / EASYFSEL.C next >
Encoding:
C/C++ Source or Header  |  1989-04-05  |  6.1 KB  |  179 lines

  1. /********************************************************************/
  2. /*    EASYFSEL.C                                                                                                            */
  3. /*                                                                                                                                    */
  4. /*    Routine zum leichten und AES-Versions abhängigen Aufruf der            */
  5. /*    GEM-Fileselectorbox mit Auswertung des 'FSEL' - Cookies.                */
  6. /*    Außerdem sind einige Routinen zum Umgang mit Dateien enthalten,    */
  7. /*    sowie zum Suchen eines Cookies.                                                                    */
  8. /*                                                                                                                                    */
  9. /*    Version : 1.27                                                                                                    */
  10. /*    Datum   : 15.06.1992                                                                                        */
  11. /*    Autor        : Andreas Papula                                                                                */
  12. /*                                                                                                                                    */
  13. /*    Copyright 1992 by MAXON Computer GmbH                                                        */
  14. /********************************************************************/
  15.  
  16. /*------------------------------------------------------------------*/
  17. /*    Include-Files einbinden.                                                                                */
  18. /*------------------------------------------------------------------*/
  19.  
  20. #include <aes.h>
  21. #include <ext.h>
  22. #include <stdio.h>
  23. #include <stdlib.h>
  24. #include <string.h>
  25. #include <tos.h>
  26. #include <portab.h>
  27. #include "easyfsel.h"
  28.  
  29. /*------------------------------------------------------------------*/
  30. /*    BOOLEAN easy_fsel(BYTE *pfad, BYTE *dateiname, BYTE *text)            */
  31. /*                                                                                                                                    */
  32. /*    Zeigt die Fileselectorbox je nach AES-Version und 'FSEL'-Cookie    */
  33. /*    an und übernimmt die Auswertung.                                                                */
  34. /*    Bei einer AES-Version >= 0x0014 oder gesetztem 'FSEL-Cookie'        */
  35. /*    wird fsel_exinput() aufgerufen, sonst fsel_input().                            */
  36. /*                                                                                                                                    */
  37. /*    Parameter:Pfad und Dateiname, mit denen die Fileselectorbox         */
  38. /*                        aufgerufen werden soll.                                                                */
  39. /*    Rückgabe :TRUE, wenn alles glattging und der Benutzer OK ge-        */
  40. /*                        drückt hat, FALSE falls ein Fehler aufgetreten ist        */
  41. /*                        oder Abbruch gewählt wurde.                                                        */
  42. /*                        Der neue Pfad steht in 'pfad', der ausgewählte Datei-    */
  43. /*                        name in 'dateiname'.                                                                    */
  44. /*------------------------------------------------------------------*/
  45.  
  46. BOOLEAN easy_fsel(BYTE *pfad, BYTE *dateiname, BYTE *text)
  47. {
  48.     WORD button;
  49.     WORD result;
  50.     LONG c_wert = 0;
  51.     extern GEMPARBLK _GemParBlk;
  52.  
  53.     /* Entsprechend der Version und des 'FSEL' - Cookies */
  54.     /* fsel_input() oder fsel_exinput() aufrufen */
  55.  
  56.     if(_GemParBlk.global[0] < 0x0014 && get_cookie("FSEL", &c_wert) == FALSE)
  57.         result = fsel_input(pfad, dateiname, &button);
  58.     else
  59.         result = fsel_exinput(pfad, dateiname, &button, text);
  60.  
  61.     /* Wenn Fehler aufgetreten oder Abbruch ausgewählt */
  62.     if(result == 0 || button == 0)
  63.         return FALSE;
  64.     else
  65.         return TRUE;
  66. }
  67.  
  68. /*------------------------------------------------------------------*/
  69. /*    VOID build_filename(BYTE *dest, BYTE *pfad, BYTE *dateiname)        */
  70. /*                                                                                                                                    */
  71. /*    Bastelt Pfad- und Dateinamen zusammen.                                                    */
  72. /*                                                                                                                                    */
  73. /*    Parameter:dest      = Zielstring.                                                                */
  74. /*                        pfad      = Pfadname.                                                                    */
  75. /*                        dateiname = Dateiname.                                                                */
  76. /*    Rückgabe :Das Ergebnis befindet sich in dest.                                        */
  77. /*------------------------------------------------------------------*/
  78.  
  79. VOID build_filename(BYTE *dest, BYTE *pfad, BYTE *dateiname)
  80. {
  81.     BYTE *xyz;
  82.  
  83.     strcpy(dest, pfad);
  84.     xyz = strrchr(dest, (int) '\\');
  85.     strcpy(++xyz, dateiname);
  86. }
  87.  
  88. /*------------------------------------------------------------------*/
  89. /*    BOOLEAN exist(const BYTE *dateiname)                                                        */
  90. /*                                                                                                                                    */
  91. /*    Überprüft, ob die Datei 'dateiname' existiert.                                    */
  92. /*                                                                                                                                    */
  93. /*    Parameter:Name der Datei.                                                                                */
  94. /*    Rückgabe :TRUE, falls die Datei existiert, FALSE wenn nicht.        */
  95. /*------------------------------------------------------------------*/
  96.  
  97. BOOLEAN exist(const BYTE *dateiname)
  98. {
  99.     if(Fsfirst(dateiname, FA_READONLY | FA_HIDDEN | FA_SYSTEM |
  100.                                                 FA_ARCHIVE) == 0)
  101.         return TRUE;
  102.     else
  103.         return FALSE;
  104. }
  105.  
  106. /*------------------------------------------------------------------*/
  107. /*            BYTE *get_akt_path(BYTE *path)                                                            */
  108. /*                                                                                                                                    */
  109. /*            Gibt das aktuelle Laufwerk und dessen Pfad zurück.                    */
  110. /*                                                                                                                                    */
  111. /*            Parameter: Zeiger auf einen String.                                                    */
  112. /*            Rückgabe : Zeiger auf das aktuelle Laufwerk und Directory.    */
  113. /*------------------------------------------------------------------*/
  114.  
  115. BYTE *get_akt_path(BYTE *path)
  116. {
  117.     strcpy(path, " :");
  118.     path[0] = 'A' + getdisk();  /* Laufwerk */
  119.     getcurdir(0, path+2);                /* Directory */
  120.     return(path);
  121. }
  122.  
  123. /*------------------------------------------------------------------*/
  124. /*    BOOLEAN get_cookie(BYTE *cookie_name, LONG *cookie_value)                */
  125. /*                                                                                                                                    */
  126. /*    Sucht nach einem Cookie 'cookie_name' und liefert dessen Wert        */
  127. /*    in 'cookie_value' zurück.                                                                                */
  128. /*                                                                                                                                    */
  129. /*    Parameter:Name des Cookies und einen Zeiger auf den Wert des        */
  130. /*                        Cookies.                                                                                            */
  131. /*    Rückgabe :TRUE, falls der Cookie gefunden wurde, FALSE falls        */
  132. /*                        nicht.                                                                                                */
  133. /*                        In 'cookie_value' steht der Wert des Cookies.                    */
  134. /*------------------------------------------------------------------*/
  135.  
  136. BOOLEAN get_cookie(BYTE *cookie_name, LONG *cookie_value)
  137. {
  138.     LONG alter_stack;
  139.     LONG *cookiejar;
  140.  
  141.     /* Zuerst einen Zeiger auf den Cookiejar holen */
  142.  
  143.     alter_stack = Super (0L);
  144.     cookiejar = *((LONG **) 0x5a0L);
  145.     Super((VOID *) alter_stack);
  146.  
  147.     /* Ist der Cookiejar vorhanden ? */
  148.     
  149.     if(!cookiejar)
  150.         return FALSE;
  151.     else
  152.     {
  153.         do
  154.         {
  155.             /* Ist es unser Cookie ? */
  156.             if(!strncmp((BYTE *)cookiejar, cookie_name, 4))
  157.             {
  158.                 /* Wenn kein NULL-Zeiger, dann Wert des Cookies 
  159.                      eintragen und TRUE zurückgeben */
  160.  
  161.                 if(cookie_value)
  162.                 {
  163.                     *cookie_value = cookiejar[1];
  164.                     return TRUE;
  165.                 }
  166.             }    
  167.             else
  168.             {
  169.                 /* nächster Cookie aus Jar */
  170.                 cookiejar = &(cookiejar[2]);
  171.             }
  172.         } 
  173.         while(cookiejar[0]);  /* solange nicht NULL-Cookie */
  174.     
  175.         return FALSE;
  176.   }
  177. }
  178.  
  179. /*----------------------- Ende der Datei. --------------------------*/